#include "boss.h"

Boss::Boss(QPixmap sprite) {
    this->setPixmap(sprite);
    this->setPos(GameDefine::ScreenWidth / 2 - sprite.width() / 2, 64);

    attackTimer = new QTimer(this);
    connect(attackTimer, &QTimer::timeout, this, &Boss::bossShoot);
    attackTimer->start(GameDefine::BossFireTime);
}

Boss::~Boss() {}

void Boss::hit() {
    this->health--;
    deathCheck();
}

void Boss::deathCheck() {
    if (health == 0) {
        attackTimer->stop();
        emit bossDefeated();
    }
}
